package cz.jm.web.jmlib.client.dialog.validation.validators;

import cz.jm.web.jmlib.client.dialog.validation.HasValidationValue;
import cz.jm.web.jmlib.client.dialog.validation.Validator;

/** Validator kontrolujuci neprazdnost vstupu. */
public abstract class RequiredValueValidator implements Validator {	
	
	public abstract String getValue();
	
	@Override
    public boolean validate() {	    
	    return !getValue().isEmpty();
    }

	@Override
    public String getValidationFailMessage() {
		return constants.requiredValue();
	}

	
	public static RequiredValueValidator createValidator(final HasValidationValue x) {
		return new RequiredValueValidator() {
			
			@Override
			public String getValue() {
				return x.getValidationValue();
			}
		};
	}
}
